// 将一些公有配置只写一份，然后暴露，别人只需要引入，然后使用就可以
export const mixin = {
    computed: {
        topic() {
            const { topic } = this.$store.state.topicAbout;
            return topic;
        },
    },
    methods: {
        setOptValue(oldOpt, newOpt) {
            const idx = this.topic.opts.indexOf(oldOpt);
            this.$set(this.topic.opts, idx, newOpt);
        },
    },
    mounted() {
        this.$store.commit("topicAbout/SET_CURRENTTYPE", this.questionType);
        this.$store.commit("topicAbout/INIT_TOPIC", this.topicTemplate);
    },
}
// life can be more interesting.
export const uploadImage = {
    data() {
        return {
            imgSrc: ""
        }
    },
    methods: {
        // 上传前的回调
        beforeUpload(file) {
            const reader = new FileReader();
            reader.readAsDataURL(file)
            reader.onload = e => {
                this.imgSrc = e.target.result
            }
        },
        // 上传后的回调
        onUploaded(url) {
            this.imgSrc = url
        }
    },

}